<?php
header('Content-Type: application/json');

//python执行部分,不带参数

function doPython($command){
    $output=shell_exec("$command 2>&1");
    return $output;
}
function Tojson($data){
    $json=array(
        "code"=>200,
        "msg"=>"数据请求成功",
        "result"=>json_decode($data,false)
    );

    return json_encode($json,false);
}

//1.主页请求
function get_pageData($command){
    $data=doPython($command);
//    print_r($data);
    $json=Tojson($data);
    echo $json;
    return $json;
}


//2.影片详情请求
function get_detail($command){
    $data=doPython($command);
//    print_r($data);
    $json=Tojson($data);
//    echo urldecode($json);
    echo $json;
    return $json;
}


//3.播放影片
function get_play($command){
    $url=doPython($command);
//    echo $url;
    return $url;
}









//入口函数
if($_GET['page']=='index'){
    $command="python /www/wwwroot/default/6v/htmlMannger.py ".$_GET['index'];
    get_pageData($command);
}
//影片详情
if($_GET['page']=='detail'){
    $movieId=$_GET['movieId'];
    $command="python /www/wwwroot/default/6v/detailManager.py ".$movieId;
    get_detail($command);
}
//影片播放
if($_GET['page']=='play'){
    $playurl="\"{$_GET['playurl']}&id={$_GET['id']}&pathid1={$_GET['pathid1']}&bf={$_GET['bf']}\"";
//    echo $playurl;
    $command="python /www/wwwroot/default/6v/playManager.py {$playurl}";
//    echo $command;
    echo get_play($command);
}